Demon possession is the superstitious explanation people came up with centuries ago, for certain kinds of mental illnesses before they understood their real causes and how the brain works.
Even visions of spirits and the supernatural is linked to the mind. The koine greek word for spiritism is the same root word from which we get pharmacy. "Spiritists" used mind altering drugs which cause them to hallucinate. They wrongly believed that their hallucinations were real encounters with the spirit world. Belief in demon possession and spiritism thus originated with superstition and ignorance of the brain's ability to formulate life-like hallucinations due to mental illness and mind-altering drugs. Instead of realizing that the hallucinations are caused by the intoxicated brain, the ancients wrongly thought that the mind-altering drugs opened doorway to the spirit world.